home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / Libraries / mymenv-notify 2.0 / vmyAEvents.cc < prev    next >
C/C++ Source or Header  |  1995-06-15  |  1KB  |  58 lines

  1. //************************************************************************
  2. //             Verify handling of mandatory AppleEvents
  3.  
  4. #include "mymenv.h"
  5. #include "myAEvents.h"
  6.  
  7. void main(void)
  8. {
  9.   Initialize_MAC();
  10.   
  11.   class Open_appl : AppleEventOpenAppl
  12.   {
  13.     OSErr operator() (void)    { alert("Got OpenAppl Event"); return noErr; }
  14.   };
  15.   Open_appl open_appl;
  16.   
  17.   class Open_doc
  18.   {
  19.   public:
  20.     Open_doc(const int no_items) { alert("%d items to open",no_items); }
  21.     Boolean operator () (AliasHandle file_spec)
  22.       { alert("document to open '%s'",get_full_path(file_spec));
  23.         return TRUE; }
  24.   };
  25.   AppleEventOpenDoc<Open_doc> open_doc;
  26.  
  27.   QuitFlag quit_flag;
  28.   
  29.   const long event_timeout = 20;
  30.   EventRecord    theEvent;
  31.  
  32.   notify("Entering the event loop... Press any key or send a Quit event to stop");
  33.   
  34.   while( !quit_flag.quitting() )
  35.   {
  36.     if( !WaitNextEvent(everyEvent, &theEvent, event_timeout, nil) )
  37.        continue;            // got null event, do nothing
  38.  
  39.     switch( theEvent.what )
  40.     {
  41.       case kHighLevelEvent:    // All High-level events we're going to receive
  42.            do_well( AEProcessAppleEvent(&theEvent) ); // are Apple events
  43.            continue;
  44.  
  45.       case keyDown:
  46.       case autoKey:
  47.        break;        // Any key quits
  48.        
  49.       default:
  50.            continue;
  51.     }
  52.     break;
  53.   }
  54.   
  55.   if( quit_flag.quitting() )
  56.     alert("Must've got quit event");
  57.  
  58. }